package com.ruoyi.common.enums.business;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum TaskCheckStatusEnum {

    ORIGINAL(0, "初始状态"),

    CHECK_PASS(1, "审核通过"),

    CHECK_PASS_NOT(2, "审核不通过"),

    CHECKED(3, "已审核"),


    ;

    private final Integer status;

    private final String desc;


    private static final Map<Integer, TaskCheckStatusEnum> ENUM_MAP;

    static {
        TaskCheckStatusEnum[] values = values();
        Map<Integer, TaskCheckStatusEnum> enToCn = new HashMap<>(values.length);
        for (TaskCheckStatusEnum value : values) {
            enToCn.put(value.getStatus(), value);
        }
        ENUM_MAP = Collections.unmodifiableMap(enToCn);
    }

    /**
     * 根据类型查找枚举
     */
    public static TaskCheckStatusEnum getEnumByType(Integer status) {
        TaskCheckStatusEnum taskCheckStatusEnum = ENUM_MAP.get(status);
        if (ObjectUtil.isEmpty(taskCheckStatusEnum)) {
            throw new RuntimeException("状态有误");
        }
        return taskCheckStatusEnum;
    }


}
